-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[bug] Fix inconsistent final plan for tgw association/propagation #44542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
TL;DRWe discussed long-standing inconsistencies in how Direct Connect and Transit Gateway attachment dependencies are handled. The consensus was to simplify behavior, remove legacy workarounds, and rely on the attachment ID being available directly from the resource rather than through a data source chain. Discussion Summary
Lesson learned: when resource chaining is needed, prefer exposing computed attributes (e.g., IDs) directly on the source resource instead of forcing users through data sources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Warning This Issue has been closed, meaning that any additional comments are much easier for the maintainers to miss. Please assume that the maintainers will not see them. Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed. |
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Description
Forensic Report: Transit Gateway Route Table Association/Propagation ForceNew Behavior
Executive Summary
This report documents the history of
ForceNew
behavior changes inaws_ec2_transit_gateway_route_table_association
andaws_ec2_transit_gateway_route_table_propagation
resources, the problems they attempted to solve, the new problems they created, and justification for reverting the changes.Timeline of Events
Original State (Pre-v5.87.0)
transit_gateway_attachment_id
hadForceNew: true
March 2023: Issue #30085 Reported
allowed_prefixes
onaws_dx_gateway_association
caused unnecessary recreation ofaws_ec2_transit_gateway_route_table_association
aws_ec2_transit_gateway_dx_gateway_attachment
to get attachment IDaws_dx_gateway_association.allowed_prefixes
changed, Terraform deferred the data source read to apply timetransit_gateway_attachment_id
unknown during planningForceNew: true
on unknown value triggered replacementApril 2024: Issue #36889 Reported
February 2025: PR #41292 - First Workaround Attempt
aws_ec2_transit_gateway_route_table_association
ForceNew: true
fromtransit_gateway_attachment_id
CustomizeDiff
logic to conditionally applyForceNew
July 2025: PR #43405 - Second Workaround Attempt
aws_ec2_transit_gateway_route_table_propagation
CustomizeDiff
logic from PR Avoid recreating aws_ec2_transit_gateway_route_table_association when unnecessary #41292July 2025: PR #43436 - Proper Solution for DX Gateway
aws_dx_gateway_association
transit_gateway_attachment_id
attributeAugust 2025: Issue #43706 Reported
CustomizeDiff
workaround logic is fundamentally flawedCustomizeDiff
logic incorrectly assumes it won't changeTechnical Analysis
The Fundamental Flaw
The
CustomizeDiff
logic attempts to distinguish between two scenarios:Scenario A (Intended to handle):
Scenario B (Fails to handle):
The logic cannot distinguish between these scenarios because both present identically during planning:
Why the Logic Fails
The condition that allows update-in-place:
This assumption is incorrect when the attachment resource itself is being replaced.
Breaking Change Justification
Is Restoring ForceNew a Breaking Change?
Technically: Yes. Changing from non-ForceNew to ForceNew is considered breaking because it changes resource replacement behavior.
Practically: No, for the following reasons:
1. The Current Behavior is Broken
The
CustomizeDiff
workaround produces incorrect plans that fail during apply with "inconsistent final plan" errors. This is not a working feature - it's a bug that causes:2. Limited Actual Impact
The
CustomizeDiff
logic only prevents ForceNew in very specific conditions:In most real-world scenarios, the logic still forces recreation. The only scenarios where it prevents recreation are:
For Scenario B, users would need to be:
This is a narrow use case.
3. The Workaround Was Short-Lived
The workaround has not been in place long enough for widespread adoption.
4. The Proper Solution Exists
PR #43436 (v6.5.0) provided the correct solution for DX Gateway scenarios by exposing
transit_gateway_attachment_id
directly onaws_dx_gateway_association
. Users should migrate to using this attribute instead of data source lookups.For VPC attachments, the attachment ID is already available as the resource's
id
attribute, so no data source is needed.5. Reverting Prevents Data Loss
The current behavior can cause:
Restoring
ForceNew: true
may cause unnecessary recreations in some edge cases, but it will never cause the "inconsistent final plan" error or leave resources in a destroyed state.Recommendation
Revert the CustomizeDiff workaround and restore ForceNew: true because:
Migration Path for Users
For DX Gateway Users (Scenario A)
Before (using data source):
After (using direct attribute - requires v6.5.0+):
For VPC Attachment Users
Correct approach (no data source needed):
Conclusion
Restoring
ForceNew: true
is justified as a bug fix rather than a breaking change because:The lesson learned: Expose computed attributes directly rather than attempting to predict when unknown values will change.
Relations
Closes #43706
References
Output from Acceptance Testing